package com.xia.mail;

public class MailUtils {
	MailSender mailSender = new MailSender();
	MailInfo mailInfo = new MailInfo();
	// 收件人地址
	String[] toAddress;
	// 邮件主题
	String subject;
	// 邮件的文本内容
	String content;

	public MailUtils(MailInfo mailInfo ,String[] toAddress, String subject, String content) {
		this.mailInfo= mailInfo;
		this.toAddress = toAddress;
		this.subject = subject;
		this.content = content;
	}

	public void sendMail() {
		String[] str = toAddress;// 收件人地址
		mailInfo.setToAddress(str);
		mailInfo.setSubject(subject);
		mailInfo.setContent(content);
		try {
			mailSender.sendTextMail(mailInfo);
			System.out.println("发送成功");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
